package com.hctg.forced2sleep.widget;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.AttributeSet;

import androidx.appcompat.widget.AppCompatTextView;

/* loaded from: classes.dex */
public class ProgressBar extends AppCompatTextView {

    /* renamed from: e  reason: collision with root package name */
    private Paint paint;

    /* renamed from: f  reason: collision with root package name */
    private RectF rectF;
    private long  progress;
    private long  max = 100L;
    private int backgroundColor = Color.parseColor("#21244A");
    private int  frontColor = Color.parseColor("#55CA9B");

    public ProgressBar(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
    }

    public int getBackgroundColor() {
        return this.backgroundColor;
    }

    public int getFrontColor() {
        return this.frontColor;
    }

    @Override
    public void onDraw(Canvas canvas) {
        int measuredHeight = getMeasuredHeight();
        int measuredWidth = getMeasuredWidth();
        int i = measuredHeight / 2;
        this.paint.setColor(this.backgroundColor);
        RectF rectF = this.rectF;
        float f2 = measuredWidth;
        rectF.right = f2;
        float f3 = measuredHeight;
        rectF.bottom = f3;
        float f4 = i;
        canvas.drawRoundRect(rectF, f4, f4, this.paint);
        RectF rectF2 = this.rectF;
        long j = this.progress;
        float f5 = (int) (((1.0f * f2) * ((float) j)) / ((float) this.max));
        rectF2.right = f5;
        if (f5 > f2) {
            rectF2.right = f2;
        }
        if (rectF2.right < f3 && j > 0) {
            rectF2.right = f3;
        }
        this.paint.setColor(this.frontColor);
        canvas.drawRoundRect(this.rectF, f4, f4, this.paint);
        super.onDraw(canvas);
    }

    @Override
    public void onFinishInflate() {
        super.onFinishInflate();
        Paint paint = new Paint();
        this.paint = paint;
        paint.setStyle(Paint.Style.FILL);
        this.paint.setColor(-3355444);
        this.paint.setAntiAlias(true);
        this.rectF = new RectF(0.0f, 0.0f, 0.0f, 0.0f);
    }

    @Override
    public void setBackgroundColor(int backgroundColor) {
        this.backgroundColor = backgroundColor;
    }

    public void setFrontColor(int frontColor) {
        this.frontColor = frontColor;
    }

    public void setMax(long max) {
        this.max = max;
    }

    public void setProgress(long progress) {
        this.progress = progress;
        postInvalidate();
    }
}
